package com.book.controller;

import com.book.entity.User;
import com.book.format.Result;
import com.book.page.Page;
import com.book.service.UserService;
import org.apache.ibatis.annotations.Param;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;


/**
 * Created by Mikey on 2017/6/10.
 */
@Controller
public class UserController {

    private Logger log = Logger.getLogger(UserController.class);
    @Resource
    private UserService userService;

    @RequestMapping("/userManage.json")
    public String userManage(Model model){
        model.addAttribute("main","user-manage.jsp");
        return "/background/index";
    }

    @RequestMapping("/getUserList.json")
    @ResponseBody
    public Result getUserList(Page page){
        return userService.getUserList(page);
    }

    @RequestMapping("/deleteUser.json")
    @ResponseBody
    public Result deleteUser(String uid){
        return userService.deleteUser(uid);
    }

    @RequestMapping("addOrEditUser.json")
    @ResponseBody
    public Result addOrEditUser(User user){
        return userService.addOrEditUser(user);
    }

    @RequestMapping("excelUser.json")
    @ResponseBody
    public Result excelUser(String id){
        return userService.excelUser(id);
    }
}
